package wang.yangziqing.app_kotlin.ui.fragment

import android.os.Bundle
import android.preference.Preference
import android.preference.PreferenceFragment
import android.preference.PreferenceScreen
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
import wang.yangziqing.app_kotlin.R
import wang.yangziqing.app_kotlin.ui.activity.AboutActivity

/**
 * Created by Administrator on 2017/11/29.
 */
class SettingFragment:PreferenceFragment() {
    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
        addPreferencesFromResource(R.xml.setting)
        return super.onCreateView(inflater, container, savedInstanceState)
    }

    override fun onPreferenceTreeClick(preferenceScreen: PreferenceScreen?, preference: Preference?): Boolean {
        val key = preference?.key
        when(key){
            "about"->startActivity<AboutActivity>()
            "clearcache"->toast("清除缓存")
        }


        return super.onPreferenceTreeClick(preferenceScreen, preference)

    }


}